import time

from selenium.webdriver.common.by import By
from Base import Base
class Page(Base):
    # 1.输入账号
    user_loc=(By.XPATH,'/html/body/div[1]/div/section/section/main/div[1]/div[2]/div[1]/div/input')
    def username(self,username):
        self.send_keys(self.user_loc,username)
    # 2.输入密码
    pwd_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div[1]/div[2]/div[2]/div/input')
    def password(self,password):
        self.send_keys(self.pwd_loc, password)
    # 3.点击登录
    login_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div[1]/div[2]/button[2]/span')
    def login(self):
        self.click(self.login_loc)
    # 4.点击确认
    queren_loc=(By.XPATH,'/html/body/div[1]/div/section/section/main/div[2]/div/div/div/div[2]/button[2]/span')
    def queren(self):
        self.click(self.queren_loc)

    # 登录逻辑业务
    def login_luoji(self,username,password):
        self.open_url('http://localhost:8081/lxyk5login')
        time.sleep(2)
        # 1.输入账号
        self.username(username)
        time.sleep(1)
        # 2.输入密码
        self.password(password)
        time.sleep(1)
        # 3.点击登录
        self.login()
        time.sleep(1)
        # 4.点击确认
        self.queren()
        time.sleep(1)
        # 窗口切换
        self.new_windows()
        time.sleep(2)